//
//  TargetTableViewCell.m
//  GOGOTravel
//
//  Created by dllo on 16/1/28.
//  Copyright © 2016年 果果. All rights reserved.
//

#import "TargetTableViewCell.h"
#import "Spot.h"
@implementation TargetTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
    }
    return self;
}

- (void)setModel:(Spot *)model{
    if (_model != model) {
        [_model release];
        _model = [model retain];
    }
    
    [self setValues];
}

- (void)setValues{
    NSDictionary *target = _model.target;
    [_imagevIEW sd_setImageWithURL:[NSURL URLWithString:target[@"cover"]] placeholderImage:[UIImage imageNamed:PLACE_HLODER]];
    _LABEL.text = target[@"title"];
    _LABEL8.text = @"点击查看详情";
}

- (void)awakeFromNib {
    // Initialization code
    if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"yeJianMoShi"] isEqualToString:@"isDay"]) {
        self.backgroundColor = DAYCOLOR;
    }else{
        self.backgroundColor = NIGHTCOLOR;
    }
    
    


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changeColor:) name:@"yeJianMoShi" object:nil];
}

- (void)changeColor:(NSNotification *)notification{
    
    if ([[[NSUserDefaults standardUserDefaults]objectForKey:@"yeJianMoShi"]isEqualToString:@"isNight"]) {
        self.backgroundColor = NIGHTCOLOR;
    }else{
        
        self.backgroundColor = DAYCOLOR;
    }
    
    
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"changeColor" object:nil];
    [_imagevIEW release];
    [_LABEL release];
    [_BUTTON1 release];
    [_LABEL8 release];
    [super dealloc];
}
- (IBAction)buttonAction:(id)sender {
    NSDictionary *dic = _model.target;
    [self.delegate JumpTOweb:dic[@"url"]];
}
@end
